//banner
Page({
    data: {
        // 下拉菜单
        first: '最新',
        second: '知识点',
        _num: 0,
        _res: 0,
        flag: true,
        current: '0',
        tab1: true,
        //tab2: true,
        data2: [
            {
                section: "数与代数",
                url: "../section/section"
            },
            {
                section: "双曲线",
                url: "../section/section"
            },
            {
                section: "三角函数",
                url: "../section/section"
            },
            {
                section: "一元二次方程",
                url: "../section/section"
            }],
        data: [],
        // 筛选
        array: [{name: '全部'}, {name: '最近一周'}, {name: '最近一个月'}, {name: '最近三个月'}],
        currentTab: 0,
        one: 0,
        two: 0,
        third: 0,
        four: 0,
        five: 0,
        six: 0,
        seven: 0,
        isShow: true,
    },


    toErrDetail:function(){
      wx.navigateTo({
        url: '../errordetails/errordetails'
      })
    },
    toPass: function () {
        wx.navigateTo({
            url: '../pass/pass'
        })
    },
    // 下拉切换
    hideNav: function () {
        this.setData({
            displays: "none"
        })
    },

    tabNav: function (e) {
        if (this.data.flag == true) {
            this.setData({
                displays: "block"
            })
        }
        if (this.data.flag == false) {
            this.setData({
                flag: true
            })
        }

        this.setData({
            tab1: true,
            tab2: false
        })
        if (this.data.currentTab === e.target.dataset.current) {
            return false;
        } else {
            var showMode = e.target.dataset.current == 0;
            console.log("showmore"+showMode)
            console.log("currentTab"+e.target.dataset.current)
            this.setData({
                currentTab: e.target.dataset.current,
                isShow: showMode
            })
        }
    },
    tabNav2: function (e) {
        this.setData({
            flag: false
        })
        this.setData({
            displays: null
        })
        this.setData({
            tab1: false,
            tab2: true
        })
        if (this.data.currentTab === e.target.dataset.current) {
            return false;
        } else {
            var showMode = e.target.dataset.current == 0;
            console.log("showmore2"+showMode)
            console.log("currentTab2"+e.target.dataset.current)
            this.setData({
                currentTab: e.target.dataset.current,

                isShow: showMode
            })
        }
    },


    // 筛选
    choseTxtColor: function (e) {
        var id = e.currentTarget.dataset.id;  //获取自定义的ID值
        console.log(e.currentTarget.dataset.id)
        this.setData({
            one: id
        })
    },
    onLoad: function (options) {
      var that = this;
      console.log(options.unionid);
        wx.setNavigationBarTitle({
            title: options.subject
        })
      wx.request({
        url: 'http://localhost:8080/eb-back-web/problem',
        method: 'post',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: { subject: options.subject,unionid:options.unionid },
        success: function (res) {
          console.log(res.data);
          that.setData({
            data:res.data
          })
        },
        fail: function () {
          console.log('系统错误')
        }
      })
    },
  problemDetail(e){
    var that = this;
    var id = e.currentTarget.id;
    wx.navigateTo({
      url: "../errordetails/errordetails?pid=" + id,
      success: function () { }        //成功后的回调；
    })
  }
})
